package com.ncst.backend.service.impl;

import com.ncst.backend.domain.Department;
import com.ncst.backend.mapper.DepartmentMapper;
import com.ncst.backend.service.DepartmentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 科室服务实现类
 */
@Slf4j
@Service
public class DepartmentServiceImpl implements DepartmentService {
    
    @Autowired
    private DepartmentMapper departmentMapper;
    
    @Override
    public Department getById(Integer id) {
        return departmentMapper.selectById(id);
    }
    
    @Override
    public List<Department> getAll() {
        return departmentMapper.selectAll();
    }
    
    @Override
    public List<Department> getByCondition(Department department) {
        return departmentMapper.selectByCondition(department);
    }
    
    @Override
    public List<Department> getByPage(Integer pageNum, Integer pageSize) {
        Integer offset = (pageNum - 1) * pageSize;
        return departmentMapper.selectByPage(offset, pageSize);
    }
    
    @Override
    public Long countAll() {
        return departmentMapper.countAll();
    }
    
    @Override
    public Long countByCondition(Department department) {
        return departmentMapper.countByCondition(department);
    }
    
    @Override
    public boolean save(Department department) {
        return departmentMapper.insert(department) > 0;
    }
    
    @Override
    public boolean saveBatch(List<Department> list) {
        return departmentMapper.insertBatch(list) > 0;
    }
    
    @Override
    public boolean updateById(Department department) {
        return departmentMapper.updateById(department) > 0;
    }
    
    @Override
    public boolean removeById(Integer id) {
        return departmentMapper.deleteById(id) > 0;
    }
    
    @Override
    public boolean removeByIds(List<Integer> ids) {
        return departmentMapper.deleteByIds(ids) > 0;
    }
}
